from appium import webdriver
import time
import random

desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = 'moniqi'
# desired_caps['appPackage'] = 'com.android.settings'
# desired_caps['appActivity'] = '.Settings'
# desired_caps['appPackage'] = 'com.android.contacts'
# desired_caps['appActivity'] = '.activities.PeopleActivity'
desired_caps['appPackage'] = 'com.cyanogenmod.filemanager'
desired_caps['appActivity'] = '.activities.NavigationActivity'

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

driver.find_element_by_id("com.cyanogenmod.filemanager:id/ab_actions").click()
time.sleep(1)
driver.find_element_by_xpath("//*[@text='新建文件夹']").click()
time.sleep(1)
driver.find_element_by_xpath("//*[@text='新建文件夹']").send_keys("%010d" % random.randint(0, 9999999999))
time.sleep(1)
driver.find_element_by_xpath("//*[@text='确定']").click()



time.sleep(3)
driver.quit()
